package cn.edu.sjtu.software.sjtucontacts.service.security;

import java.io.InputStream;
import java.io.OutputStream;

public class SecurityManager {
	public static OutputStream encrypt(int encryptionAlgorithmId, String path) throws Exception{
		EncryptAlgorithmFactory factory = new EncryptAlgorithmFactory(encryptionAlgorithmId);
		IEncryption encryptionAlgorithm = factory.getEncryptionAlgorithm();
		return encryptionAlgorithm.encrypt(path);
	}
	public static InputStream decrypt(int encryptionAlgorithmId, String path) throws Exception{
		EncryptAlgorithmFactory factory = new EncryptAlgorithmFactory(encryptionAlgorithmId);
		IEncryption encryptionAlgorithm = factory.getEncryptionAlgorithm();
		return encryptionAlgorithm.decrypt(path);
	}
}
